package com.example.demo_mysql_mybatisplus.customized;

import com.example.customized.apis.ExtendApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@RequestMapping("cc")
public class CustomizedController3 {

    @Autowired(required = false)
    ExtendApi extendApi;

    /** 动态的 额外 扫描配置：原功能增强示例  */
    @GetMapping("/get")
    public void get(){

        Object obj = Optional.ofNullable(extendApi).map(e -> e.demo(1) ).orElse(null)  ;
        System.out.println( obj );

        if(null!=extendApi){
            System.out.println( "增强场景执行 " + extendApi.demo()  );
        }else{
            System.out.println( "增强场景不执行 " );
        }

    }
}